package com.atguigu.springcloud.alibaba.controller;

import com.atguigu.springcloud.alibaba.service.AccountService;
import com.atguigu.springcloud.entities.CommonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @Author: shikong
 * @Date: 2020/8/13 22:54
 */

@RestController
@Slf4j
public class AccountController {

    @Resource
    private AccountService accountService;

    /**
     * 扣减账户余额
     */

    @PostMapping(value = "/account/decrease")
    public CommonResult decrease(@RequestParam(value = "userId")Long userId, @RequestParam(value = "money")BigDecimal money){


        log.info("扣减余额微服务方法执行");
        accountService.decrease(userId,money);

        return new CommonResult(200,"successful","扣减账户余额成功");
    }


}
